package com.lyf.learn.atsgg.spring.transaction.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @AUTHOR LYF
 * @DATE 2022/5/26
 * @VERSION 1.0
 * @DESC
 */
@Repository
public class AccountDaoImpl implements AccountDao{
    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public void addAccount(String name, Integer money) {
        String sql = "UPDATE account_test SET " +
                "account = account+? WHERE name = ?";
        jdbcTemplate.update(sql,money,name);
    }

    @Override
    public void decrAccount(String name, Integer money) {
        String sql = "UPDATE account_test SET " +
                "account = account-? WHERE name = ?";
        jdbcTemplate.update(sql,money,name);
    }


}
